<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- echo输出变量，字符串等等 -->
    <?php
    $x=5;
    $y=6;
    $z=$x+$y;
    echo $z;
    echo "<br>";
    echo $name;
    ?>
    <!-- 字符串函数 -->
        <!-- 字符串的长度 -->
    <?php 
    echo "字符串的长度：".strlen("Hello world!");
    echo "<br>";
    ?>
        <!-- 字符串的字符索引 -->
    <?php 
    echo "字符串的字符索引".strpos("hello world!","d");
    echo "<br>";
    ?>
        <!-- 替换字符串的文本 -->
    <?php 
        echo str_replace("world","kity","hello world!");
        echo "<br>";
    ?>
    <!-- 标签 -->
    <p>{$name1}</p>

    <!-- 常量 -->
    <?php
      define("pel","hfihaiofhoaihf");
        echo pel;
        echo "<br>";
    ?>
    <a href="{$href}">点击一下</a>
    <br>

    <!-- 数组 -->
        <!-- 索引数组 -->
    <?php
    $cars=array();
    $cars[0] = "porsche";
    $cars[1] = "dafafad";
    $cars[2] = "porsfafche";
    echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

    echo "<br>";
    ?>
        <!--关联数组  -->
        <?php
        $age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43","sex"=>"男");
        echo "Peter is " . $age['Peter'] . " "."性别：".$age['sex']." years old.";
        echo "<br>";
        //输出数组的长度
        echo "数组的长度=".count($age);

        echo "<br>";
        //遍历关联数组--foreach()
        foreach($age as $key=>$value)
        {
            echo "key=".$key."，"."value=".$value;
            echo "<br>";
        }
        ?>
        
        
</body>
</html>